package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConComplaintType;
import com.htgd.gardenexpo.dao.GeConComplaintTypeDao;
import com.htgd.gardenexpo.service.GeConComplaintTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 投诉建议类型(GeConComplaintType)表服务实现类
 *
 * @author makejava
 * @since 2021-06-08 17:21:27
 */
@Service("geConComplaintTypeService")
public class GeConComplaintTypeServiceImpl implements GeConComplaintTypeService {
    @Resource
    private GeConComplaintTypeDao geConComplaintTypeDao;

    /**
     * 通过ID查询单条数据
     *
     * @param complaintTypeId 主键
     * @return 实例对象
     */
    @Override
    public GeConComplaintType queryById(Integer complaintTypeId) {
        return this.geConComplaintTypeDao.queryById(complaintTypeId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConComplaintType> queryAllByLimit(int offset, int limit) {
        return this.geConComplaintTypeDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param geConComplaintType 实例对象
     * @return 实例对象
     */
    @Override
    public GeConComplaintType insert(GeConComplaintType geConComplaintType) {
        this.geConComplaintTypeDao.insert(geConComplaintType);
        return geConComplaintType;
    }

    /**
     * 修改数据
     *
     * @param geConComplaintType 实例对象
     * @return 实例对象
     */
    @Override
    public GeConComplaintType update(GeConComplaintType geConComplaintType) {
        this.geConComplaintTypeDao.update(geConComplaintType);
        return this.queryById(geConComplaintType.getComplaintTypeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param complaintTypeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer complaintTypeId) {
        return this.geConComplaintTypeDao.deleteById(complaintTypeId) > 0;
    }
}
